package viewcomponents;

import java.awt.Dimension;
import java.io.IOException;

import javax.swing.*;

import controller.Controller;

/**
 * This class creates a basic workspace in each tab
 * It also manages all tabs
 * If a tab(workspace) is switched, it relates the selected tab with command input
 *
 */
public class SLogoTabManager extends JTabbedPane {
	
	private Controller myController;
	
	public SLogoTabManager(String tabName, Controller controller)
	{
		myController = controller;
		addTab(tabName, myController);
		setVisible(true);
	}
	
	/**
	 * 
	 * @return currently selected turtle canvas
	 */
	public TurtleCanvas getTurtleCanvas()
	{
		return ((SLogoCanvas)getSelectedComponent()).getTurtleCanvas();
	}
	
	/**
	 * Set tab size as preferred size
	 * Notice: it will change sizes for all tabs simultaneously
	 */
	public void setSize(Dimension dimension) {
		setPreferredSize(dimension);
	}
	
	/**
	 * Add new tab(workspace) to GUI
	 * @param tabName
	 * @param controller
	 */
	public void addTab(String tabName, Controller controller)
	{
		addTab(tabName, new SLogoCanvas(controller));
	}
	
	/**
	 * 
	 * @return user command from typing
	 */
	public String getInput() {
		SLogoCanvas canvas = (SLogoCanvas) getSelectedComponent();
		return canvas.getInput();
	}
	
	/**
	 * Remove tab(workspace) from GUI
	 */
	public void removeTab() {
		// TODO implement
	}
	
	
}
